home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / dist-packages / GDebi / DscSrcPackage.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  3.0 KB  |  86 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import apt_inst
  5. import apt_pkg
  6. import apt
  7. import sys
  8. import os
  9. from gettext import gettext as _
  10. from DebPackage import DebPackage
  11. from Cache import Cache
  12.  
  13. class DscSrcPackage(DebPackage):
  14.     
  15.     def __init__(self, cache, file = None):
  16.         DebPackage.__init__(self, cache)
  17.         self.file = file
  18.         self.depends = []
  19.         self.conflicts = []
  20.         self.binaries = []
  21.         if file != None:
  22.             self.open(file)
  23.         
  24.  
  25.     
  26.     def getConflicts(self):
  27.         return self.conflicts
  28.  
  29.     
  30.     def getDepends(self):
  31.         return self.depends
  32.  
  33.     
  34.     def open(self, file):
  35.         depends_tags = [
  36.             'Build-Depends:',
  37.             'Build-Depends-Indep:']
  38.         conflicts_tags = [
  39.             'Build-Conflicts:',
  40.             'Build-Conflicts-Indep:']
  41.         for line in open(file):
  42.             for tag in depends_tags:
  43.                 if line.startswith(tag):
  44.                     key = line[len(tag):].strip()
  45.                     self.depends.extend(apt_pkg.ParseSrcDepends(key))
  46.                     continue
  47.             
  48.             for tag in conflicts_tags:
  49.                 if line.startswith(tag):
  50.                     key = line[len(tag):].strip()
  51.                     self.conflicts.extend(apt_pkg.ParseSrcDepends(key))
  52.                     continue
  53.             
  54.             if line.startswith('Source:'):
  55.                 self.pkgName = line[len('Source:'):].strip()
  56.             
  57.             if line.startswith('Version:'):
  58.                 self._sections['Version'] = line[len('Version:'):].strip()
  59.             
  60.             if line.startswith('-----BEGIN PGP SIGNATURE-'):
  61.                 break
  62.                 continue
  63.         
  64.         s = _("Install Build-Dependencies for source package '%s' that builds %s\n") % (self.pkgName, ' '.join(self.binaries))
  65.         self._sections['Description'] = s
  66.  
  67.     
  68.     def checkDeb(self):
  69.         if not self.checkConflicts():
  70.             for pkgname in self._installedConflicts:
  71.                 if self._cache[pkgname]._pkg.Essential:
  72.                     raise Exception, _('A essential package would be removed')
  73.                 self._cache[pkgname]._pkg.Essential
  74.                 self._cache[pkgname].markDelete()
  75.             
  76.         
  77.         return self._satisfyDepends(self.depends)
  78.  
  79.  
  80. if __name__ == '__main__':
  81.     cache = Cache()
  82.     s = DscSrcPackage(cache)
  83.     d = 'libc6 (>= 2.3.2), libaio (>= 0.3.96) | libaio1 (>= 0.3.96)'
  84.     print s._satisfyDepends(apt_pkg.ParseDepends(d))
  85.  
  86.